//
//  STTools_HomeTableViewCell.m
//  FindFriend
//
//  Created by apple on 2020/9/3.
//  Copyright © 2020 stoneobs. All rights reserved.
//

#import "THGoodCollectionViewCell.h"


@interface THGoodCollectionViewCell()
@property(nonatomic, strong) UIImageView                     *iconImagView;/**<  */
@property(nonatomic, strong) STLabel                     *nameLable;/**<  */
@property(nonatomic, strong) STLabel                     *priceLable;/**<  */
@property(nonatomic, strong) UIView                     *whiteView;/**<  */
@property(nonatomic, strong) CALayer                     *sublayer;/**<  */
@end
@implementation THGoodCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self stoneobs_ui_configSubView];
    }
    return self;
}

#pragma mark --configSubView
- (void)stoneobs_ui_configSubView{
    self.whiteView = UIView.new;
    self.whiteView.backgroundColor = UIColor.whiteColor;
    self.whiteView.layer.cornerRadius = 4;
    self.whiteView.clipsToBounds = YES;
    [self addSubview:self.whiteView];
    
    UIImageView * icon_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH - 30, UISCREEN_WIDTH - 30)];
    icon_imageView.image = [UIImage imageNamed:@"ic_none"];
    icon_imageView.contentMode = UIViewContentModeScaleAspectFill;
    icon_imageView.clipsToBounds = YES;
    [self addSubview:icon_imageView];
    self.iconImagView = icon_imageView;

    
    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(5, 0, self.iconImagView.width - 10, 35)
                                                                text:@"#可爱萝莉、魅力大方、甜..."
                                                           textColor:STONEOBS_UI_FIRST_TEXT_COLOR
                                                                font:12
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        self.nameLable = stoneobs_ui_label;
        [self addSubview:stoneobs_ui_label];
    });
    
    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(5, 0, self.iconImagView.width - 10, 20)
                                                                text:@"#可爱萝莉、魅力大方、甜..."
                                                           textColor:WH_UICOLOR_FROM_RGBA(0xFF6955)
                                                                font:18
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        self.priceLable = stoneobs_ui_label;
        [self addSubview:stoneobs_ui_label];
    });
}
- (void)setModel:(THGoodModel *)model{
    _model = model;
    [self.iconImagView sd_setImageWithURL:model.img.mj_url];


    self.nameLable.text = model.name;
    self.priceLable.text = [NSString stringWithFormat:@"￥%@",model.price];
    self.priceLable.attributedText = [self.priceLable.text stoneobs_fun_st_convertAttributeStringWithKeyWord:@"￥" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];
}
- (void)layoutSubviews{
    
    self.whiteView.frame = self.bounds;
    [self.sublayer removeFromSuperlayer];
    self.sublayer =  [self.whiteView stoneobs_fun_st_showRoundLayer];

    
    self.priceLable.bottom = self.height - 5;
    self.nameLable.bottom = self.priceLable.top - 3;
    
    self.iconImagView.frame = CGRectMake(0, 0, self.width, self.nameLable.top - 3);
}
@end
